using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WbsEditor
{
    public partial class EnterTfsUrlForm : Form
    {
        public EnterTfsUrlForm()
        {
            InitializeComponent();
        }

        public string TfsUrl
        {
            get { return _tfsUrlTextBox.Text; }
            set { _tfsUrlTextBox.Text = value; }
        }

        public string UserName
        {
            get { return _userName.Text; }
            set { _userName.Text = value; }
        }

        public string Domain
        {
            get { return _domain.Text; }
            set { _domain.Text = value; }
        }

        public string Password
        {
            get { return _password.Text; }
            set { _password.Text = value; }
        }

        [Browsable(true)]
        public bool UseWindowsAuthentication
        {
            get
            {
                if (_authenticationMethodCombo.SelectedIndex == 1)
                {
                    return false;
                }
                return true;
            }

            set
            {
                if (value)
                {
                    _authenticationMethodCombo.SelectedIndex = 0;
                }
                else
                {
                    _authenticationMethodCombo.SelectedIndex = 1;
                }
                CheckEnableUserPassword();
            }
        }

        private void _authenticationMethodCombo_SelectedIndexChanged(object sender, EventArgs e)
        {
            CheckEnableUserPassword();
        }

        private void CheckEnableUserPassword()
        {
            bool enable = false;
            if (_authenticationMethodCombo.SelectedIndex == 1)
            {
                enable = true;
            }

            _userName.Enabled = enable;
            _domain.Enabled = enable;
            _password.Enabled = enable;
            _userNameLabel.Enabled = enable;
            _domainLabel.Enabled = enable;
            _passwordLabel.Enabled = enable;
        }
    }
}